package com.his.outpatientvisit.service.impl;

import com.his.login.entity.DictEmployee;
import com.his.outpatientvisit.dao.PatiOutVisitInvoiceLinkMapper;
import com.his.outpatientvisit.entity.PatiOutVisitInvoiceLink;
import com.his.outpatientvisit.service.PatiOutVisitInvoiceLinkService;
import com.his.outpatientvisit.vo.PatiOutVisitInvoiceLinkVo;
import com.xiao.common.util.BeanUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class PatiOutVisitInvoiceLinkServiceImpl implements PatiOutVisitInvoiceLinkService {
    @Resource
    private PatiOutVisitInvoiceLinkMapper patiOutVisitInvoiceLinkMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void insertPatiOutVisitInvoiceLink(DictEmployee employee, PatiOutVisitInvoiceLinkVo patiOutVisitInvoiceLinkVo,String settleId) throws Exception{
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date today= new Date();
        Date insertdate = simpleDateFormat.parse(simpleDateFormat.format(today));
        Date updatedate = simpleDateFormat.parse(simpleDateFormat.format(today));
        PatiOutVisitInvoiceLink patiOutVisitInvoiceLink = BeanUtil.copyBean(patiOutVisitInvoiceLinkVo,PatiOutVisitInvoiceLink.class);
        patiOutVisitInvoiceLink.setSettleid(employee.getEMPID());
        patiOutVisitInvoiceLink.setCreatetime(insertdate);
        patiOutVisitInvoiceLink.setSettleid(settleId);
//        patiOutVisitInvoiceLink.setUpdatedate(updatedate);
        patiOutVisitInvoiceLinkMapper.invoicelink_add(patiOutVisitInvoiceLink);
    }
}
